<?php
$smarty->configLoad($lang . '/report.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['answer_report'];
if(isset($_POST['submit'])) {
	$sql = 'INSERT INTO '.DB_CMS.'.module_preport_answers (reportID, adminID, title, message) VALUES (:reportID, :adminID, :title, :message)';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':reportID', $_GET['id']);
	$dbh->bindValue(':adminID', $_SESSION['id']);
	$dbh->bindValue(':title', $_POST['title']);
	$dbh->bindValue(':message', $_POST['message']);#
	$dbh->execute();
	if(isset($_POST['close'])) {
		$sql = 'UPDATE '.DB_CMS.'.module_preport SET status = 2 WHERE id = :id';
		$dbh = $connection->prepare($sql);
		$dbh->bindValue(':id', $_GET['id']);
		$dbh->execute();
	} else {
		$sql = 'UPDATE '.DB_CMS.'.module_preport SET status = 1 WHERE id = :id';
		$dbh = $connection->prepare($sql);
		$dbh->bindValue(':id', $_GET['id']);
		$dbh->execute();
	}
	$main->jqmodal('replayed');
	echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=report&page=detail&id='.$_GET['id'].'">';

}
$template = 'report/answer.tpl';
?>
